<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
    <script type="text/javascript" src="./lib/angularJS/angular.min.js"></script>

    <title>活动审核</title>

    <style type="text/css">
        .pager {
            display: inline-flex;
            margin-top: 10px;
        }

        .page-container {
            text-align: center;
        }

        .pager>nav {
            display: flex;
            align-items: center;
            padding: 3px;
        }

        .pager>nav>button {
            margin-left: 3px;
        }

        .pager>nav>ol[data-role="pageNumbers"]>li {
            margin-left: 3px;
            cursor: pointer;
        }

        .pager>nav>ol[data-role="pageNumbers"] {
            display: flex;
        }

        .pager>nav>ol[data-role="pageNumbers"]>li.current {
            background-color: #5a98de;
            color: white;
        }

        .table-border {
            border-top: 1px solid #5a98de;
        }

        .table-bordered th,
        .table-bordered td {
            border-color: #5a98de;
        }
    </style>

</head>

<body ng-app="myApp" ng-controller="myCorl">
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span> 活动管理
        <span class="c-gray en">&gt;</span> 活动审核
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
            title="刷新">
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>
    <div class="page-container">

        <div class="mt-20">
            <input type="text" class="btn btn-primary-outline radius" name="" ng-model="searchInfo"  placeholder="用户名" style="width:250px;margin-bottom: 10px" class="input-text">
            <button style="margin-bottom: 10px" class="btn btn-primary-outline radius" type="submit" ng-click="submit(searchInfo);">
                <i class="Hui-iconfont">&#xe665;</i> 搜用户</button>
            <table class="table table-border table-bordered table-hover table-bg table-sort">
                <thead>
                    <tr class="text-c">
                        <th width="30">ID</th>
                        <th width="100">活动名称</th>
                        <th width="40">活动详情</th>
                        <th width="50">活动类型</th>
                        <th width="150">活动时间</th>
                        <th width="50">活动限制</th>
                        <th width="100">联系电话</th>
                        <th width="70">发起人</th>
                        <th width="30">互动人数</th>
                        <th width="30">已参加人数</th>
                        <th width="70">操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="text-c" ng-repeat="action in actioninfo">
                        <td>{{action.id}}</td>
                        <td>{{action.activityName}}</td>
                        <td>{{action.activityContent}}</td>
                        <td>{{action.type}}</td>
                        <td>{{action.activityDate}}</td>
                        <td>{{action.activityLimit}}</td>
                        <td>{{action.tel}}</td>
                        <td>{{action.username}}</td>
                        <td>{{action.activityNum}}</td>
                        <td>{{action.num}}</td>
                        <!-- <td>{{action.status}}</td> -->
                        <td class="td-status">
                            <button ng-click="action_pass(action.id)" class="label label-success radius">通过</button>
                            <button ng-click="action_stop(action.id)" class="label label-success radius">不通过</button>
                        </td>

                    </tr>
                </tbody>
            </table>
            <!-- <div class="pager"> </div> -->
        </div>
    </div>
</body>

<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>

<script src="./lib/pagejs/dom/index.js"></script>
<script src="./lib/pagejs/bom/index.js"></script>
<script src="./lib/pagejs/pager/index.js"></script>


<!-- <script type="text/javascript">
    let app = angular.module('myApp', []);
    app.controller('myCorl', ['$scope', '$http', function ($scope, $http) {

        $scope.action_pass = function (id) {
            layer.confirm('通过该活动？', {
                    btn: ['通过', '取消'],
                    shade: false,
                    closeBtn: 0
                },
                function () {
                    $http({
                        method: 'GET',
                        url: 'http://localhost/xiaojv/Api/index.php?p=back&m=actionAudit&a=actionPass',
                        headers: {
                            'Content-Type': 'application/x-www-form-urlencoded'
                        },
                        params: {
                            id
                        }
                    }).then(function successCallback(response) {
                        if (response.data) {
                            layer.msg('已通过', {
                                icon: 6,
                                time: 1000
                            }, function () {
                                window.location.reload();
                            });
                        } else {
                            layer.msg('服务器异常，未能通过该活动', {
                                icon: 6,
                                time: 1000
                            });
                        }
                    });
                });
        }

        $scope.action_stop = function (id) {
            layer.confirm('不通过该活动？', {
                    btn: ['不通过', '取消'],
                    shade: false,
                    closeBtn: 0
                },
                function () {
                    $http({
                        method: 'GET',
                        url: 'http://localhost/xiaojv/Api/index.php?p=back&m=actionAudit&a=actionBan',
                        headers: {
                            'Content-Type': 'application/x-www-form-urlencoded'
                        },
                        params: {
                            id
                        }
                    }).then(function successCallback(response) {
                        if (response.data) {
                            layer.msg('已不通过', {
                                icon: 6,
                                time: 1000
                            }, function () {
                                window.location.reload();
                            });
                        } else {
                            layer.msg('服务器异常，未能不通过该活动', {
                                icon: 6,
                                time: 1000
                            });
                        }
                    });
                });
        }

        $scope.pagerFun = function (row) {
            let pager = document.querySelector('.pager')
            new Pager({
                element: pager,
                currentPage: 1,
                totalPage: row,
            })
            let btn = document.querySelectorAll('.pager button')
            btn.forEach(function (btn) {
                btn.classList.add('btn', 'btn-primary-outline', 'radius')
            })
            let li = document.querySelectorAll('ol li')
            li.forEach(function (li) {
                li.classList.add('btn', 'btn-primary-outline', 'radius')
            })
            pager.addEventListener('pageChange', (e) => {
                console.log(e.detail.page)
                $scope.httpFun(e.detail.page - 1);
            })
        }


        $http({
            method: 'GET',
            url: 'http://localhost/xiaojv/Api/index.php?p=back&m=actionAudit&a=pager',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },
        }).then(function successCallback(response) {
            let row = response.data;
            $scope.pagerFun(parseInt(row));
        })


        $scope.httpFun = function (page) {
            $http({
                method: 'GET',
                url: 'http://localhost/xiaojv/Api/index.php?p=back&m=actionAudit&a=actionAudit',
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                },
                params: {
                    page
                }
            }).then(function successCallback(response) {
                console.log(response);
                $scope.actioninfo = response.data;
            }, function errorCallback(response) {
                console.log(response)
            });
        }
        $scope.httpFun(0);

    }])
</script> -->

<script type="text/javascript">
    let app = angular.module('myApp', []);
    app.controller('myCorl',['$scope', '$http',function ($scope, $http) {
        $scope.currentPage = 0;
        let pager;
        let mt = document.querySelector('.mt-20')
        let information;
        $scope.submit = function(searchInfo){
            information = searchInfo
            $scope.httpFun(0)
        }
        $scope.httpFun = function(page){
            var page = page || 0 
            if(information){
                $http({
                    method: 'GET',
                    url: '../Api/index.php?p=back&m=actionAudit&a=Search',
                    headers : {'Content-Type':'application/x-www-form-urlencoded'},
                    params: { 
                        page,
                         searchInfo : information
                    } 
                }).then(function successCallback(response) {
                    $scope.actioninfo = response.data;
                    $scope.pagerSelect(page+1);
                    if($scope.actioninfo.length === 0){
                        $scope.httpFun($scope.currentPage-1,information);
                    }
                })
                return
            }
            $http({
                method: 'GET',
                url: '../Api/index.php?p=back&m=actionAudit&a=actionAudit',
                headers : {'Content-Type':'application/x-www-form-urlencoded'},
                params: { 
                     page
                } 
            }).then(function successCallback(response) {
                $scope.actioninfo = response.data;
                $scope.pagerSelect(page+1);
                if($scope.actioninfo.length === 0){
                    $scope.httpFun($scope.currentPage-1,information);
                }
            }, function errorCallback(response) {
                console.log(response)
            });
        }
        $scope.httpFun($scope.currentPage);
        
        $scope.pagerFun = function(page,row){
            pager = document.createElement('div')
            pager.className = 'pager'
            mt.appendChild(pager)
            new Pager({
              element: pager,
              currentPage: page,
              totalPage: row,
            })
            let btn = document.querySelectorAll('.pager button')
            btn.forEach(function(btn){
                btn.classList.add('btn','btn-primary-outline','radius')
            })
            let li = document.querySelectorAll('ol li')
            li.forEach(function(li){
                li.classList.add('btn','btn-primary-outline','radius')
            })
            pager.addEventListener('pageChange', $scope.pageChange)
        }
        $scope.pageChange = function(e){
            $scope.currentPage = e.detail.page-1;
            $scope.httpFun($scope.currentPage,information);
        }
        $scope.pagerSelect = function(page){
            if(information){
                $http({
                    method: 'GET',
                    url: '../Api/index.php?p=back&m=actionAudit&a=Pagersearch',
                    headers : {'Content-Type':'application/x-www-form-urlencoded'},
                    params: { 
                         searchInfo: information
                    } 
                }).then(function successCallback(response) {
                    let row = response.data;
                    
                    if($scope.currentPage == row){
                        page = row
                        
                    }
                    console.log(row);
                    pager.removeEventListener('pageChange', $scope.pageChange)
                     mt.removeChild(pager)
                    $scope.pagerFun(page,parseInt(row));
                })
                return
            }
            $http({
                method: 'GET',
                url: '../Api/index.php?p=back&m=actionAudit&a=Pager',
                headers : {'Content-Type':'application/x-www-form-urlencoded'},
            }).then(function successCallback(response) {
                if(pager){
                    pager.removeEventListener('pageChange', $scope.pageChange)
                    mt.removeChild(pager)
                }
                let row = response.data;
                if($scope.currentPage == row){
                    page = row
                }
                $scope.pagerFun(page,parseInt(row));
            })
        }

        $scope.action_pass = function (id){
            layer.confirm('通过该活动？', {
                btn: ['通过','取消'], 
                shade: false,
                closeBtn: 0
            },
            function(){
                $http({
                    method: 'GET',
                    url: '../Api/index.php?p=back&m=actionAudit&a=actionPass',
                    headers : {'Content-Type':'application/x-www-form-urlencoded'},
                    params: { 
                         id
                    } 
                }).then(function successCallback(response) {
                    if(response.data){
                        $scope.httpFun($scope.currentPage,information);
                        layer.msg('已通过', {icon:6,time:1000});
                    }else{
                        layer.msg('服务器异常，未能通过活动', {icon:6,time:1000});
                    }
                })
            });	
        }

        $scope.action_stop = function (id){
            layer.confirm('不通过该活动？', {
                btn: ['不通过','取消'], 
                shade: false,
                closeBtn: 0
            },
            function(){
                $http({
                    method: 'GET',
                    url: '../Api/index.php?p=back&m=actionAudit&a=actionBan',
                    headers : {'Content-Type':'application/x-www-form-urlencoded'},
                    params: { 
                         id
                    } 
                }).then(function successCallback(response) {
                    if(response.data){
                        $scope.httpFun($scope.currentPage,information);
                        layer.msg('已不通过', {icon:6,time:1000});
                    }else{
                        layer.msg('服务器异常，未能不通过该活动', {icon:6,time:1000});
                    }
                })
            });	
        }

    }])
</script>



</html>